package cn.gqr.controller.Public;


import cn.gqr.entity.User;
import cn.gqr.service.UserService;
import cn.gqr.uitl.RespJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
public class LoginController {

    @Autowired
    private UserService us;

    @RequestMapping("/login")
    public String login(){
        return "login/login";
    }

    @RequestMapping({"/","/index"})
    public String index(){
        return "index";
    }

    @RequestMapping("/goRegister")
    public String goRegister(){
        return "login/register";
    }

    @RequestMapping("/register")
    @ResponseBody
    public Map register(@RequestBody User user){
        System.out.println(user);
        return RespJson.pack(200,"..",us.addUser(user));
    }


}
